<template>
    <div>
        <h1><a href="#" style="color:blue">{{nickName}}</a>欢迎登入</h1>
        <!-- <button @click="add">+</button>
        <button @click="minutes">-</button> -->
        <!-- <button @click="add(119)">mapMutations传参</button> -->
        <button @click="add(120)">mapActions</button>
    </div>
</template>
<script>
// mapState
import { mapState } from "vuex"; //辅助函数
import { mapMutations } from "vuex"; //mutation的辅助函数
import { mapActions } from "vuex";
export default {
  //在计算属性里面 使用mapState
  computed: mapState([
    "nickName" //这种写法 必须是传入的字符串和store里面state的名字是一样的
  ]),

  //   methods: {
  //     ...mapMutations({
  //       add: "incretment", //映射 为 this.$store.commit('incretment')
  //       minutes:'decretment'
  //     })
  //   }
  //   methods: {
  //     ...mapMutations(["add"])
  //   }
  //   created() {
  //     this.$store.dispatch("add", 666);
  //   }
  methods: {
      ...mapActions([
          'add'
      ])
  }
};
</script>
